package stream.test;

import java.util.ArrayList;
import java.util.function.Consumer;
import java.util.stream.Stream;

/*
    男演员只要名字为三个字的前两个人
    女演员只要姓林的，不要第一个
    两个过滤后合并到一块
    把上一步数据创建对象Actor，遍历数据
 */
public class StreamTest1 {
    public static void main(String[] args) {
        ArrayList<String> manList = new ArrayList<>();
        manList.add("姚明");
        manList.add("郭艾伦");
        manList.add("张学友");
        manList.add("薛之谦");
        manList.add("张学良");
        ArrayList<String> womanList = new ArrayList<>();
        womanList.add("章若男");
        womanList.add("林心如");
        womanList.add("柳岩");
        womanList.add("范冰冰");
        womanList.add("林志玲");

        Stream<String> stream1 = manList.stream().filter(s -> s.length() == 3).limit(2);
        Stream<String> stream2 = womanList.stream().filter(s -> s.startsWith("林")).skip(1);
        Stream<String> conStream = Stream.concat(stream1, stream2);
        conStream.forEach(new Consumer<String>() {
            @Override
            public void accept(String name) {
                Actor a = new Actor(name);
                System.out.println(a);
            }
        });
    }
}
